#ifndef DATAMODEL_H
#define DATAMODEL_H

#include <QAbstractTableModel>
#include <QDataStream>
#include <QVector>

class DataModel : public QAbstractTableModel
{
    Q_OBJECT
public:
    explicit DataModel(QObject *parent = 0);

    void setData(const QByteArray& array);

    qint8 getQint8(const QByteArray& array) const;
    quint8 getQuint8(const QByteArray& array) const;
    qint16 getQint16(const QByteArray& array) const;
    quint16 getQuint16(const QByteArray& array) const;
    qint32 getQint32(const QByteArray& array) const;
    quint32 getQuint32(const QByteArray& array) const;
    qint64 getQint64(const QByteArray& array) const;
    quint64 getQuint64(const QByteArray& array) const;

    QByteArray fillData() const;

    QString tranqint16(const QByteArray& array) const;
    QString tranquint16(const QByteArray& array) const;
    QString tranqint32(const QByteArray& array) const;
    QString tranquint32(const QByteArray& array) const;
    QString tranqint64(const QByteArray& array) const;
    QString tranquint64(const QByteArray& array) const;

signals:

public slots:
    void littleEndian(bool checked);

protected:
    void init(void);

private:
    QVector<QString> types;
    QByteArray array;
    QDataStream::ByteOrder byteOrder;

    // QAbstractItemModel interface
public:
    int rowCount(const QModelIndex &parent) const;
    int columnCount(const QModelIndex &parent) const;
    QVariant data(const QModelIndex &index, int role) const;
};

#endif // DATAMODEL_H
